/*=========================================================================
The Impact of Denying a Wanted Abortion on Women and Children
Authors: Juliana Londoño-Vélez and Estefanía Saravia

Creation date: January 9th, 2024
--------------------------------------------------------------------------
Table 1 - Summary Statistics
=========================================================================*/


use "$data/Final_Tutelas_Medellin.dta", replace


global outcomes Mujer_Ponente Niega Acepta Improcedente
global outcomes2 id_demandante id_oficina id_juez
 

mat 	a = J(8,2,.)


matrix rownames a =  $outcomes "N" $outcomes2 

local i=1
foreach var in $outcomes {

sum `var' 

mat a[`i',1]=(r(mean))*100

sum  `var'  if Caso_Aborto==1

mat a[`i',2]=(r(mean))*100
local i=`i'+1
}

* N
count 
mat a[5,1]=r(N)

count if Caso_Aborto==1
mat a[5,2]=r(N)

local i=6
foreach var in $outcomes2 {

egen nvals=nvals(`var')

sum nvals

mat a[`i',1]=r(mean)
drop nvals

egen nvals=nvals(`var') if Caso_Aborto==1

sum nvals

mat a[`i',2]=r(mean)
drop nvals
local i=`i'+1
}


	svmat2 a, rnames(outcome)
	
	drop if outcome==""
	rename a1 any_tutela
	rename a2 abortion

	
	keep outcome any_tutela abortion
	
	order outcome any_tutela abortion
	
	export excel using "$output/Tables paper matrices replication.xlsx", sheet("Table 1", modify) 
	
	